<?php
header("Content-Type: text/html; charset=utf-8");
$tm = $_GET['tm'];
$da = json_decode($tm,true);
switch ($da[0]) {
	case A: $xz='capricorn'; $mc="♑️摩羯座" ;break;
	case B: $xz='aquarius'; $mc="♒️水瓶座" ;break;
	case C: $xz='pisces'; $mc="♓️双鱼座" ;break;
	case D: $xz='aries'; $mc="♈️牡羊座" ;break;
	case E: $xz='taurus'; $mc="♉️金牛座" ;break;
	case F: $xz='gemini'; $mc="♊️双子座" ;break;
	case G: $xz='cancer'; $mc="♋️巨蟹座" ;break;
	case H: $xz='leo'; $mc="♌️狮子座" ;break;
	case I: $xz='virgo'; $mc="♍️处女座" ;break;
	case J: $xz='libra'; $mc="♎️天秤座" ;break;
	case K: $xz='scorpio'; $mc="♏️天蝎座" ;break;
	case L: $xz='sagittarius'; $mc="♐️射手座" ;break;
}
$str=file_get_contents('http://app.data.qq.com/?umod=astro&act=astro&jsonp=1&func=TodatTpl&t=4&a='.$xz.'&y=2019&m='.date(m).'&d='.date(d));
$str = substr($str , 9,-2);
$arr=json_decode($str,true);
$arr2=array();
$arr3=array();
foreach($arr['fortune'] as $val){
	$arr2[]=$val['type'];
	$arr3[]=$val['content'];
};
$arr4=array();
for($i=0;$i<4;$i++){
	$ys= substr($arr3[$i+1],0,2);
	if($ys>=90){$arr4[$i]=5;}
	elseif($ys>=80){$arr4[$i]=4;}
	elseif($ys>=60){$arr4[$i]=3;}
	elseif($ys>=40){$arr4[$i]=2;}
	else{$arr4[$i]=3;}
}
$data=array('csm'=>$mc."的今日运势",'dfjs'=>"综合运势：",'df'=>$arr3[0],'bq1' =>"情运".$arr3[1],'bq2'=>"事运".$arr3[2],'bq3'=>"财运".$arr3[3],'bq4'=>"健康".$arr3[4],'bq5'=>"颜色".$arr3[5],'bq6' =>"数字".$arr3[6],'bq7'=>"速配".$arr3[7],'bq8'=>null,'pf1' =>$arr4[0],'pf2'=>$arr4[1],'pf3'=>$arr4[2],'pf4'=>$arr4[3],'pf5'=>5,'pf6' =>5,'pf7'=>5);
echo json_encode($data,JSON_UNESCAPED_UNICODE);
$conn = new mysqli('127.0.0.1', '3h74cu729i222', 'gm666946','3h74cu729i222');
$conn ->set_charset("utf8");
$sql = "SELECT * FROM sjtj WHERE num = 0";
$res=$conn->query($sql);
$data=$res->fetch_all();
$sccs=$data[0][5]+1;
$sql = "UPDATE sjtj SET xpzcscs = '$sccs' WHERE num = 0";
$res=$conn->query($sql);
$conn->close();
?>